package com.example.featuresdk.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.Text
import androidx.compose.material.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.example.featuresdk.R
import com.example.featuresdk.theme.DemoTheme
import com.example.featuresdk.viewmodel.SearchState

@Composable
inline fun FullScreen(uiConstraints: ScreenConstraints,content: @Composable () -> Unit) {

    Column(modifier = Modifier
        .background(DemoTheme.colors.background)
        .width(uiConstraints.screenWithDp.dp)
        .height(uiConstraints.screenHeightDp.dp)) {
        content()
    }
}

@Composable
inline fun AppHeaderView(heightDp: Int, content: @Composable () -> Unit){

    Row(modifier = Modifier
        .background(DemoTheme.colors.primary)
        .height(heightDp.dp)
        .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
        content()
    }
}


@Composable
inline fun AppBodyView(bodyHeightDp: () -> Dp, backgroundColor: Color = DemoTheme.colors.secondary, bodyContent: @Composable () -> Unit){

    Box(modifier = Modifier
        .height(bodyHeightDp())
        .fillMaxWidth()
        .background(backgroundColor)) {
        bodyContent()
    }
}

@Composable
inline fun AppBottomView(heightDp: () -> Dp, content: @Composable () -> Unit){

    Box(modifier = Modifier
        .height(heightDp())
        .fillMaxWidth()
        .background(DemoTheme.colors.primary)) {
        content()
    }
}

@Composable
inline fun AppBottomView(modifier:Modifier = Modifier.fillMaxSize(), content: @Composable () -> Unit){

    Box(modifier = modifier.background(DemoTheme.colors.primary)) {
        content()
    }
}

@Composable
fun AppHeaderTitle(title:String = "", headerWidthDp:Int){
    Text(text = title,
        modifier = Modifier.width(headerWidthDp.dp),
        style = DemoTheme.typography.header,
        color = contentColorFor(DemoTheme.colors.primary))
}

@Composable
inline fun AppHeaderContainer(heightDp: Int, content: @Composable () -> Unit){
    Row(modifier = Modifier
        .background(DemoTheme.colors.primary)
        .height(heightDp.dp)
        .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {

        content()
    }
}

@Composable
inline fun AppRowContainer(heightDp: Dp, content: @Composable () -> Unit) {

    Row(modifier = Modifier
        .height(heightDp)
        .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
        content()
    }
}

//@Composable
//fun HeaderBackFeatureEntry(){
//
//    val navHostController = LocalFeatureConfiguration.current.navHostController!!
//
//    FeatureEntry(R.drawable.ic_back, onClick = {
//        navHostController.popBackStack()
//    })
//}


@Composable
fun HeaderBackFeatureEntry(onBackClicked:()->Unit){
    FeatureEntry(R.drawable.ic_back, onClick = { onBackClicked() })
}